package jjn.weekly.contest356;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * @author Jiang Jining
 * @since 2023-07-30 10:48
 */
public class LeetCode6900 {
    public int countCompleteSubarrays(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            set.add(num);
        }
        int ans = 0;
        for (int i = 0; i < nums.length; i++) {
            Set<Integer> existed = new HashSet<>();
            for (int j = i; j < nums.length; j++) {
                int num = nums[j];
                existed.add(num);
                if (existed.size() == set.size()) {
                    ans++;
                }
            }
        }
        return ans;
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int total = scanner.nextInt();
        int[] nums = new int[total];
        for (int i = 0; i < total; i++) {
            nums[i] = scanner.nextInt();
        }
        int count = new LeetCode6900().countCompleteSubarrays(nums);
        System.out.println(count);
    }
    
}
